//
//  BaseAnimationContentView.swift
//  xmly
//
//  Created by 刘文超 on 2019/12/27.
//  Copyright © 2019 刘文超. All rights reserved.
//

import UIKit

class BaseAnimationContentView: BaseTabContentView {

    
    var durtionTime = 0.2
    
    override init(frame: CGRect) {
        super.init(frame: frame)
    }
    
    override func selectAnimation(animated: Bool, completion: (() -> ())?) {
        boundsAnimation()
        completion?()
    }
    override func reselectAnimation(animated: Bool, completion: (() -> ())?) {
        boundsAnimation()
        completion?()
    }
    
    
    required init?(coder aDecoder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
    
    
    func boundsAnimation() {
        let keyAnimation = CAKeyframeAnimation.init(keyPath: "transform.scale")
        keyAnimation.values = [1.0,1.05,1.1,1.2,1.35,1.2,1.1,1.05,1.0]
        keyAnimation.duration = durtionTime * 3
        keyAnimation.fillMode = .forwards
        keyAnimation.calculationMode = .cubic
        imageView.layer.add(keyAnimation, forKey: "scale")
        
    }
    
    

}
